<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
    //let const ``  symbol  Array.form、Array.of、对象的简写、属性名表达式、set、map、解构赋值、...扩展运算符、for...of、类与继承、箭头函数、

      let y = 2;
      let obj2 = {['x'+y]:100} ;
      for(let item in obj2){
            console.log(item,obj2.item);
      }

        
// 已知数据：
    let cites = [
        { py: 'beijing', name: '北京' },
        { py: 'alishan', name: '阿里山' },
        { py: 'beidaihe', name: '北戴河' },
        { py: 'shijiazhuang', name: '石家庄' }
    ]

// 生成如下格式的数据：
    // let cityArr = [];

    // cityArr['a'] = [{ py: 'alishan', name: '阿里山' }]

    // cityArr['b'] = [{ py: 'beijing', name: '北京' },{ py: 'beidaihe', name: '北戴河' }];
    //console.log(cityArr,cityArr['b'][1].name);


    let cArr = [];
    //生成一个二维数组，这个二维数组的第一个下标是以城市拼音首字母作为下标的
    for(let obj of cites){  
        let str =  obj.py.slice(0,1)
        cArr[str] = [];
    }
   // console.log(cArr,cArr['b']);


    for(let obj2 of cites){
        let str2 = obj2.py.slice(0,1);
        cArr[str2].push(obj2)
    }

    console.log(cArr);

    </script>
</head>
<body>
    
</body>
</html>